// lua ddt UI constants

#pragma once

#include <cstdint>
#include <string>
#include <unordered_map>

#include "wx/listctrl.h"

#include "ddt/sharedDefs.h"
#include "lx/color.h"

#define 	DDT_RESTORE_FOCUS		0
#define		DDT_LOG_FOCUS_CHANGE		0

#define		DDT_SCREENCAST_DEFAULT_FLAG	false

#ifdef __WIN32__
	#define WX_STATUS_BAR_SUNKEN	 wxSB_NORMAL	// wxSB_FLAT
#else
	#define WX_STATUS_BAR_SUNKEN	 wxSB_SUNKEN
#endif

#if 1
	// (always declare, only implementation changes)
	extern
	void	DumpFocusLL(const char *fn, const char *comment);
	
	#if __gnu_linux__
		#define	DumpFocus(comm)		DumpFocusLL(__PRETTY_FUNCTION__, comm)
	#else
		#define	DumpFocus(comm)		DumpFocusLL(__FUNCTION__, comm)
	#endif
#endif

#ifdef __WIN32__
	const int	WX_LIST_AUTO_SZ = wxLIST_AUTOSIZE_USEHEADER;
#else
	const int	WX_LIST_AUTO_SZ = wxLIST_AUTOSIZE;
#endif

namespace DDT_CLIENT
{

using namespace DDT;
using LX::Color;
using LX::RGB_COLOR;

using std::string;

const uint32_t	PREFS_VERSION				= 0x03200000;
const int	TAB_NUM_CHARS				= 8;

const int	PROJECT_MRU_MAX				= 16;
const int	LOCAL_PATH_MRU_MAX			= 10;

const int	ICON_SIZE				= 16;
const int	NAVIGATION_ICON_SIZE			= 24;
const int	THROB_ICON_WIDTH			= 20;

const int	ASYNC_READ_GEAR_1_TIMER_MS		= 10;				// gear 1
const int	ASYNC_READ_GEAR_2_TIMER_MS		= 200;				// gear 2
const int	ASYNC_READ_GEAR_SWITCH_DELAY_MS		= 400;
const int	SAVE_PROJECT_PREFS_DELAY_MS		= 1000;
const int	SAVE_UI_PREFS_DELAY_MS			= 500;
const int	NOTIFICATION_MESSAGE_TIMEOUT_MS		= 3000;
const int	JWX_BIND_RETRY_MS			= 200;
const int	STC_FUNCTION_REFRESH_DELAY_MS		= 200;

const int	UDP_REFRESH_PERIOD_MS			= 1000;

const int	MOUSE_HIGHLIGHT_RADIUS_PIXELS		= 128;
const int	MOUSE_CLICK_RADIUS_TIMER_STEP_MS	= 50;
const int	MOUSE_CLICK_RADIUS_TIMER_TOTAL_MS	= 300;
const int	MOUSE_HIGHLIGHT_TIMER_TOTAL_MS		= 500;
const int	OVERLAY_W				= MOUSE_HIGHLIGHT_RADIUS_PIXELS * 2;

const int	PANEBOOK_MAX				= 3;

const int	NUM_EDIT_STATUS_FIELDS			= 4;

const int	SCRUBBER_WIDTH_PIXELS			= 12;				// delete ?

const Color	SEARCH_RESULTS_COLOR_DEFAULT		= RGB_COLOR::WHITE;
const Color	SEARCH_RESULTS_COLOR_FAIL		= RGB_COLOR::LIGHT_RED;

const Color	STARTUP_COMBO_COLOR_OK			= RGB_COLOR::WHITE;
const Color	STARTUP_COMBO_COLOR_FAIL		= RGB_COLOR::LIGHT_RED;

const string	TOP_FRAME_TITLE				= "DDT Client";
const string	DEFAULT_HOSTNAME_AND_PORT_STRING	= "localhost:3001";
const string	DEFAULT_LUA_STARTUP_STRING	 	= "script.lua:main()";
	
enum TIMER_ID : int
{
	ASYNC_READ = 0,
	UDP_REFRESH,
	
	TIMER_MAX
};
	
enum SEARCH_TOGGLE_INDEX
{
	BTN_INDEX_CASE	= 0,
	BTN_INDEX_WHOLE_WORD,
	BTN_INDEX_WILDCARD,
	BTN_INDEX_REGEX,
	BTN_INDEX_LIVE_CODE,
	BTN_INDEX_ALL_FILES,
	BTN_INDEX_HIGHLIGHT,
	
	BTN_INDEX_TOTAL
};

// notebook page indices
enum PANE_ID : int
{	
	PANE_ID_NONE = -1,
	
	PANE_ID_OUTPUT = 0,
	PANE_ID_PROJECT,
	PANE_ID_LOCALS,
	PANE_ID_GLOBALS,
	PANE_ID_WATCHES,
	PANE_ID_STACK,
	PANE_ID_BREAKPOINTS,
	PANE_ID_MEMORY,
	PANE_ID_SEARCH,
	PANE_ID_LUA_FUNCTIONS,
	PANE_ID_JUCE_LOCALS,
	
	PANE_ID_MAX,
	
	PANE_ID_ALL_VAR_VIEWS
};

enum
{
	DDT_CONTROL_ID_FIRST = 200,
	
	FRAME_ID_TOP_FRAME,
	CONTROL_ID_TOP_NOTEPANEL,
	CONTROL_ID_TOP_NOTEBOOK_IMP,
	CONTROL_ID_STC_EDITOR,
	CONTROL_ID_TOP_PANEL,
	CONTROL_ID_BOTTOM_NOTE_PANEL,
	
	FRAME_ID_OVERLAY,
	
	SPLITTER_ID_MAIN,
	SPLITTER_ID_TOP,
	SPLITTER_ID_BOTTOM,
	
	DIALOG_ID_GRID_EDIT,
	
	STATUSBAR_ID_TOOLBAR,
	TOOLBAR_ID_TOOLBAR,
	
	CONTROL_ID_CODE_EDITOR_PLACEHOLDER,
	
	CONTROL_ID_PANE_BOOK_BASE,
	CONTROL_ID_PANE_BOOK_LAST = CONTROL_ID_PANE_BOOK_BASE + PANEBOOK_MAX,
	
	CONTROL_ID_BOTTOM_NOTEBOOK_BASE,
	CONTROL_ID_BOTTOM_NOTEBOOK_LAST = CONTROL_ID_BOTTOM_NOTEBOOK_BASE + PANEBOOK_MAX,
	
	// PRISTINE preallocated wx IDs so retarded submenus can NOT be used
	PANE_ID_BODY_DOUBLE_START,
	PANE_ID_BODY_DOUBLE_END = PANE_ID_BODY_DOUBLE_START + PANE_ID_MAX,
	
	CONTROL_ID_EDITOR_STATUSBAR,
	CONTROL_ID_SEARCH_PANEL,
	CONTROL_ID_SEARCH_EDIT_CONTROL,
	CONTROL_ID_SEARCH_RESULTS_TEXT,
	
	CONTROL_ID_SCRUBBER,
	CONTROL_ID_SCRUBBER_STATIC_BITMAP,
	
	CONTROL_ID_MEMORY_VAR_NAME,
	SPIN_ID_MEMORY_HIGHLIGHT_FROM,
	SPIN_ID_MEMORY_HIGHLIGHT_TO,
	RADIO_ID_MEMORY_VIEW_HEX,
	RADIO_ID_MEMORY_VIEW_ASCII,
	BUTTON_ID_MEMORY_REFRESH,
	CONTROL_ID_MEMORY_DUMP_TEXT,
	
	CONTROL_ID_FUNCTIONS_TEXT,
	RADIO_ID_FUNCTIONS_SORT_ALPHA,
	RADIO_ID_FUNCTIONS_SORT_LINE,
	
	CONTROL_ID_GRID_IMP_PANEL,
	
	PANEL_ID_OUTPUT_TEXT_CTRL,
	PANEL_ID_PROJECT_LIST,
	PANEL_ID_LOCALS_LIST_CONTROL,
	PANEL_ID_GLOBALS_LIST_CONTROL,
	PANEL_ID_WATCH_LIST_CONTROL,
	PANEL_ID_TRACE_BACK_LIST_CONTROL,
	PANEL_ID_BREAKPOINTS_LIST_CONTROL,
	PANEL_ID_MEMORY_VIEW_CONTROL,
	PANEL_ID_SEARCH_RESULTS,
	PANEL_ID_LUA_FUNCTIONS_CONTROL,
	PANEL_ID_JUCE_LOCALS_LIST_CONTROL,
	
	BUTTON_ID_AUTO_SORT_VARS,

	FRAME_ID_SOLO_LOG,
	COMBO_ID_MAP_NAME,
	COMBO_ID_LUA_DIR,
	CONTROL_ID_DIR_PICKER,
	CONTROL_ID_MAP_LIST_CONTROL,
	
	// (for local vs remoter)
	CONTROL_ID_LOCAL_DIR,
	CONTROL_ID_LOCAL_FILTER_LIST,
	CONTROL_ID_LOCAL_NAVIGATION_BAR,
	
	CONTROL_ID_REMOTE_TREE,
	CONTROL_ID_REMOTE_FILTER_LIST,
	CONTROL_ID_REMOTE_NAVIGATION_BAR,
	
	CONTROL_ID_PANEBOOK_STATIC_BITMAP,
	
	MENU_ID_SAVE_PROJECT_AS,
	MENU_ID_CLOSE_ALL_LUA_FILES,
	MENU_ID_CLOSE_PROJECT,
	
	// edit menu
	MENU_ID_GOTO_LINE,
	TOOL_ID_SET_FIND_STRING,
	TOOL_ID_FIND,
	TOOL_ID_FIND_ALL,
	TOOL_ID_FIND_PREVIOUS,
	TOOL_ID_FIND_NEXT,
	EDIT_MENU_ID_SAVE_FILE,
	EDIT_MENU_ID_REVERT_FILE,
	MENU_ID_REFRESH_MEMORY_VIEW,
	
	// tools menu
	MENU_ID_DUMP_PANEBOOK_VARS,
	MENU_ID_FORCE_PANEBOOK_RELOAD,
	MENU_ID_NETWORK_STRESS_TEST,
	MENU_ID_DUMP_FIXED_FONT,
	MENU_ID_SERIALIZE_BITMAP_FILE,
	MENU_ID_SAVE_SCREENSHOT,
	MENU_ID_CLEAR_LOG,
	
	// options menu
	TOGGLE_MENU_ID_SHOW_VAR_PATHS,
	TOGGLE_MENU_ID_SCREENCAST_MODE,
	TOGGLE_MENU_ID_GRID_OVERLAYS,
	
	POPUP_MENU_ID_CLOSE_PANE,
	POPUP_MENU_ID_DRAG_PANE,
	POPUP_MENU_ID_SHIFT_PANE_BOOK,
	
	POPUP_MENU_ID_SET_STARTUP_SCRIPT,
	
	MAIN_TOOLBAR_ID,
	
	COMBOBOX_ID_DAEMON_HOST_N_PORT,
	COMBOBOX_ID_LUA_MAIN_SOURCE_N_FUNCTION,
	
	TEXTCTRL_ID_LUA_OUTPUT,
	EDITCTRL_ID_LUA_COMMAND,
	BUTTON_ID_SEND_LUA_COMMAND,
	BUTTON_ID_HOLD_LUA_COMMAND,
	
	LISTCTRL_ID_VAR_VIEW,
	
	// varview context menus
	VARVIEW_CONTEXT_MENU_ID_COLLAPSE_ALL_TABLES,
	
	// stc context menu
	CONTEXT_MENU_ID_STC_ADD_TO_WATCHES,
	CONTEXT_MENU_ID_STC_COPY_LUA_ERROR,
	
	LOCAL_PATH_MRU_START,
	LOCAL_PATH_MRU_END = LOCAL_PATH_MRU_START + LOCAL_PATH_MRU_MAX + 1,
	LOCAL_PATH_MRU_CLEAR,
	
	TOOL_ID_OPEN_FILES,
	TOOL_ID_SAVE_PROJECT,
	TOOL_ID_CONNECTION,
	TOOL_ID_START_RUN,
	TOOL_ID_STEP_INTO,
	TOOL_ID_STEP_OVER,
	TOOL_ID_STEP_OUT,
	TOOL_ID_TOGGLE_JIT,
	TOOL_ID_TOGGLE_LOAD_BREAK_MODE,
	TOOL_ID_TOGGLE_STEP_MODE,
	TOOL_ID_TOGGLE_BREAKPOINT,
	TOOL_ID_TOGGLE_GLOBAL_BREAKPOINTS,
	TOOL_ID_STOP,
	
	TOOL_ID_BOOKMARK_TOOGLE,
	TOOL_ID_BOOKMARK_PREV,
	TOOL_ID_BOOKMARK_NEXT,
	
	TOOL_ID_SOLO_LOG_WINDOW,
	TOOL_ID_RESET_NOTE_PANES,
	TOOL_ID_ABORT,
	
	MENU_ID_ESCAPE_KEY,
	
	// searchbar toggle button IDs
	BUTTON_ID_BASE,
	BUTTON_ID_LAST = BUTTON_ID_BASE + BTN_INDEX_TOTAL,
	
	PROJECT_MRU_START,
	PROJECT_MRU_END = PROJECT_MRU_START + PROJECT_MRU_MAX + 1,
	PROJECT_MRU_CLEAR,	
	
	TOGGLE_ID_FIRST,
	TOGGLE_ID_LAST = TOGGLE_ID_FIRST + VV_LAST_UI,
	
	// internal
	TIMER_ID_ASYNC_READ,
	TIMER_ID_CIRCLE,
	TIMER_ID_OVERLAY,
	TIMER_ID_UDP_LOG,
	
	BROADCAST_ID_STOP_SESSION,
	DBGF_ID_LUA_SUSPENDED,
	DBGF_ID_INCOMING_MESSAGE,
	BROADCAST_ID_RE_SEARCH,
	
	DDT_CONTROL_ID_LAST
};

// toolbar bitmaps
enum BITMAP_ID : int
{
	BITMAP_ID_OPEN_FILES = 0,
	BITMAP_ID_SAVE_PROJECT,
	BITMAP_ID_CONNECT,
	BITMAP_ID_DISCONNECT,
	BITMAP_ID_STOP,
	BITMAP_ID_START,
	BITMAP_ID_STEP_INTO,
	BITMAP_ID_STEP_OVER,
	BITMAP_ID_STEP_OUT,
	BITMAP_ID_TOGGLE_JIT_ENABLED,
	BITMAP_ID_TOGGLE_JIT_DISABLED,
	BITMAP_ID_TOGGLE_LOAD_BREAK,
	BITMAP_ID_TOGGLE_LOAD_CONTINUE,
	BITMAP_ID_TOGGLE_STEP_MODE_LINES,
	BITMAP_ID_TOGGLE_STEP_MODE_VM,
	BITMAP_ID_BREAKPOINTS_ENABLED,
	
	BITMAP_ID_ABORT,
	
	BITMAP_ID_SEARCH_APPLY,
	BITMAP_ID_SEARCH_UP,
	BITMAP_ID_SEARCH_DOWN,
	BITMAP_ID_SEARCH_HIGHLIGHT_ALL,
	BITMAP_ID_SEARCH_REGEX,
	
	BITMAP_ID_LAST
};

// aux bitmaps
enum AUX_BITMAP_ID : int
{
	BITMAP_ID_EMPTY_PLACEHOLDER = 0,		// need empty, transparent bitmap for non-breakpoint icon
	BITMAP_ID_RED_DOT,
	BITMAP_ID_PLUS,
	BITMAP_ID_MINUS,
	BITMAP_ID_CLOSE_TAB,
	BITMAP_ID_ARROW_RIGHT,
	BITMAP_ID_ARROW_DOWN,
	BITMAP_ID_FLASH,
	
	BITMAP_ID_AUX_BITMAP_LAST
};	

enum class COLUMN_T : int
{
	NONE = -1,
	KEY = 0,
	VAL_STR,
	VAL_TYPE,
	SCOPE,
	VAL_PATH					// (enabled on debug)
};

enum VAR_FLAGS : uint32_t
{
	VAR_FLAG_CHANGED	= (1L << 0),
	VAR_FLAG_SHOW_SCOPE	= (1L << 1),
	VAR_FLAG_EDITABLE	= (1L << 2),
	VAR_FLAG_SHOW_PATH	= (1L << 3)
};

enum VAR_UI_ID : int
{
	VAR_UI_COLUMN_HEADER = 0,
	VAR_UI_DEFAULT,
	VAR_UI_CHANGED_VAL,
	VAR_UI_EDITOR_URL,
	VAR_UI_MEMORY_URL,
	VAR_UI_METATABLE_URL,
	
	VAR_UI_DEFAULT_MONOSPACE = 80
};

enum class INIT_LEVEL : int
{
	DISCONNECTED = 0,
	CONNECTED,
	LUA_STARTED,
	LUA_RUNNING,
	LUA_PAUSED,
	WAIT_REPLY,
	LUA_FATAL_ERROR
};

enum MARGIN_MARKER_T : int
{
	EXECUTION_LINE		= 1,
	SEARCH_RESULT_LINE	= 2,
	USER_BOOKMARK		= 3
};

enum VAR_SOLVE_REQUESTER : uint32_t
{
	SOLVE_REQUESTER_ILLEGAL = 0,
	SOLVE_REQUESTER_LOCALS = 1,
	SOLVE_REQUESTER_GLOBALS,
	SOLVE_REQUESTER_WATCHES,
	SOLVE_REQUESTER_JUCE_LOCALS,
	SOLVE_REQUESTER_MEMORY_VIEW,
	SOLVE_REQUESTER_HOVER,
};

} // namespace DDT_CLIENT

// nada mas

